package ru.amse.tsyganov.jumleditor.graphicaleditor;

import java.util.HashSet;
import java.util.Set;

import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.PaintEvent;

public abstract class EditorMode {
	
	private Set<EditorModeSelectionListener> listeners = 
		new HashSet<EditorModeSelectionListener>();
	
	public abstract void mouseDoubleClick(MouseEvent e); 
	
	public abstract void mouseDown(MouseEvent e); 
	
	public abstract void mouseUp(MouseEvent e);
	
	public abstract void mouseMove(MouseEvent e);
	
	public abstract void keyPressed(KeyEvent e);
	
	public abstract void keyReleased(KeyEvent e);
	
	public abstract void paintControl(PaintEvent e, Coordinates coordinates);
	
	public abstract void initState();
	
	public boolean addSelectionListener(
			EditorModeSelectionListener listener) {
		
		return listeners.add(listener); 
	}
	
	public boolean removeSelectionListener(
			EditorModeSelectionListener listener) {
		
		return listeners.remove(listener); 
	}
	
	public void fireSelected() {
		for (EditorModeSelectionListener l : listeners) {
			l.selected();
		}
	}
	
	public void fireUnselected() {
		for (EditorModeSelectionListener l : listeners) {
			l.unselected();
		}
	}
}
